package com.Ian.homework;

/**
 * 考的是正则表达式的用法
 */
public class CountNumber {
    public static void main(String[] args) {
        String strData = "ABCD123!@#$%ab";
        System.out.println("--------大写字母-----------------");
        String strHData = strData.replaceAll("[^A-Z]","");
        System.out.println(strHData);
        System.out.println("大写字母的个数为" + strHData.length());

        System.out.println("--------小写字母-----------------");
        String strLData = strData.replaceAll("[^a-z]","");
        System.out.println(strLData);
        System.out.println("小写字母的个数为" + strLData.length());

        System.out.println("--------数字字母-----------------");
        String strDData = strData.replaceAll("[^0-9]","");
        System.out.println(strDData);
        System.out.println("数字字母的个数为" + strDData.length());

        System.out.println("--------其他字符-----------------");
        String strOData = strData.replaceAll("[a-zA-Z0-9]","");
        System.out.println(strOData);
        System.out.println("其他字符的个数为" + strOData.length());
    }
}
